package mementopattern;

import java.util.Stack;

//管理者
public class Caretaker {

    private Stack<Memento> mementoStack = new Stack<>();

    public void addMemento(Memento memento) {
        mementoStack.push(memento);
    }

    public Memento getMemento() {
        if (mementoStack.isEmpty()) {
            return null;
        }
        return mementoStack.pop();
    }
}
